import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import {baseUrl} from '@/config/env'

// 全局引入iview和iview样式
import iView from 'iview'
import 'iview/dist/styles/iview.css'
Vue.use(iView)

// 引入公共样式
import '@/style/common.less'

// 引入覆盖iview的样式
import '@/style/theme.less'

// axios配置
Vue.prototype.$axios = axios;
axios.defaults.baseURL = baseUrl;

/**
 * 全局导航守卫
 * 1.拦截登陆
 * 2.路由切换顶部动画
 */
router.beforeEach((to, from, next) => {
  iView.LoadingBar.start();
  next();
});

router.afterEach(route => {
  iView.LoadingBar.finish();
});


Vue.config.productionTip = false

// 实例化vue
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
